package agent.configuration;


import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.ResourceLoader;

import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import java.io.IOException;
import java.util.Properties;
import java.util.concurrent.ConcurrentHashMap;

@Configuration
public class ModelList
{
    public final static ConcurrentHashMap<Integer,String> modelList = new ConcurrentHashMap<>();
    private final static String resourcePath = "classpath:META-INF/";

    @Value("${ai.modelStoreFile}")
    private String modelFile;
    @Resource
    private ResourceLoader resourceLoader;

    @PostConstruct
    public   void init() throws IOException {
        org.springframework.core.io.Resource resource = resourceLoader.getResource(resourcePath + modelFile);
        Properties properties = new Properties();
        properties.load(resource.getInputStream());
          properties.forEach((k, v)->{
              modelList.putIfAbsent((Integer) k, v.toString());
          });
    }
    public static String  ChooseModel(Integer key){
        return ModelList.modelList.get(key);
    }


}
